<template>
  <el-button @click="beginAdd()" type="danger">+新增</el-button>
  <el-button @click="beginAdd()" type="danger">保存</el-button>
  <el-button @click="beginAdd()" type="danger">撤销</el-button>
  <el-button @click="beginAdd()" type="danger">删除</el-button>
  <el-table :data="tableData" style="width: 100%">
    <el-table-column property="maleBeginId" label="序号" />
    <el-table-column property="proEarBegin" label="耳号" />
    <el-table-column property="cottageTypeName" label="栋舍" />
    <el-table-column property="fieIdName" label="栏位" />
    <el-table-column property="transplainData" label="转种日期" />
    <el-table-column property="femaleBeginWeight" label="重量(公斤)" />
  </el-table>
  <br />

  <el-form-item label="备注:" prop="proSleepNotes">
    <el-input
      v-model="ruleForm.proSleepNotes"
      type="textarea"
      placeholder="请输入备注信息"
    />
  </el-form-item>
  <div>
    <el-button  link @click="addDomain()"><span style="color:red">+增行</span></el-button>
    <el-button  link @click="addDomain()"><span style="color:red">-删行</span></el-button>
  </div>
  <el-table :data="listImmunization" style="width: 100%">
    <el-table-column prop="maleBeginId" label="序号" width="180" />
    <el-table-column prop="proEarBegin" label="耳号" width="180" />
    <el-table-column prop="cottageTypeName" label="栋舍" width="180" />
    <el-table-column prop="fieIdName" label="栏位" width="180" />
    <el-table-column prop="address" label="转种日期" width="180" />
    <el-table-column prop="address" label="重量(公斤)" width="180" />
  </el-table>
</template>

<script setup lang="ts">
import { reactive, ref, onMounted } from 'vue';
import axios from 'axios';
import { useRoute, useRouter } from 'vue-router';
import { ElMessage, ElMessageBox } from 'element-plus';
const route = useRoute();
const router = useRouter();

const tableData = ref([]);
const ruleForm = reactive({
  proSleepNotes: '',
});

// const formRef = ref<FormInstance>();
const dynamicValidateForm = reactive<{
  domains: DomainItem[];
  email: string;
}>({
  domains: [
    {
      key: 1,
      value: '',
    },
  ],
  email: '',
});
interface DomainItem {
  key: number;
  value: string;
}
const removeDomain = (item: DomainItem) => {
  const index = dynamicValidateForm.domains.indexOf(item);
  if (index !== -1) {
    dynamicValidateForm.domains.splice(index, 1);
  }
};

const listImmunization = ref([]);

const addDomain = () => {
  dynamicValidateForm.domains.push({
    key: Date.now(),
    value: '',
  });
};
</script>
